import Fields from 'dependencies/Fields'
import Field from 'dependencies/Field'

export const id = new Field({
  prop: '_id',
  label: '用户ID'
})
export const avatar = new Field({
  prop: 'avatar',
  label: '头像'
})
export const username = new Field({
  prop: 'username',
  label: '用户名'
})
export const nickname = new Field({
  prop: 'nickName',
  label: '昵称'
})
export const inviter_uid = new Field({
  prop: 'inviter_uid',
  label: '邀请人'
})
export const my_invite_code = new Field({
  prop: 'my_invite_code',
  label: '邀请码'
})
export const mobile = new Field({
  prop: 'mobile',
  label: '手机号'
})
export const is_svip = new Field({
  prop: 'is_svip',
  label: '是否是超级Vip',
  enums: [{
        value: 0,
        label: "否"
      },
      {
        value: 1,
        label: "是"
      }
    ]
})
export const join_svip_time = new Field({
  prop: 'join_svip_time',
  label: '加入vip时间'
})
export const svip_expiration_time = new Field({
  prop: 'svip_expiration_time',
  label: 'vip过期时间'
})
export const total_revenue = new Field({
  prop: 'total_revenue',
  label: '总收益'
})
export const balance = new Field({
  prop: 'balance',
  label: '余额'
})
export const allow_login_background = new Field({
  prop: 'allow_login_background',
  label: '允许登录后台',
  enums: [{
      value: true,
      label: "允许",
      tagType: "success"
    },
    {
      value: false,
      label: "禁止",
      tagType: "danger"
    }
  ]
})
export const status = new Field({
  prop: 'status',
  label: '账户状态',
  type: 'select',
  enums: [{
      value: 0,
      label: "正常",
      tagType: "success"
    },
    {
      value: 1,
      label: "冻结",
      tagType: "danger"
    },
    {
      value: 2,
      label: "审核中",
      tagType: "primary"
    },
    {
      value: 3,
      label: "审核拒绝",
      tagType: "info"
    }
  ]
})
export const gender = new Field({
  prop: 'gender',
  label: '性别',
  enums: [{
        value: 0,
        label: "女"
      },
      {
        value: 1,
        label: "男"
      },
      {
        value: -1,
        label: "未知"
      }
    ]
})
export const last_login_date = new Field({
  prop: 'last_login_date',
  label: '最后登录时间'
})

export const userListFields = Object.freeze([
  id,
  my_invite_code,
  inviter_uid,
  total_revenue.setListComponent({
    props: {
      value: Object
    },
    render(h) {
      return h('span', '￥' + vk.pubfn.priceFilter(this.value) || '--')
    }
  }),
  balance.setListComponent({
    props: {
      value: Object
    },
    render(h) {
      return h('span', '￥' + vk.pubfn.priceFilter(this.value) || '--')
    }
  }),
  mobile,
  status,
  gender,
  last_login_date.setListComponent({
    props: {
      value: Object
    },
    render(h) {
      return h('span', vk.pubfn.timeFormat(new Date(this.value),"yyyy-MM-dd hh:mm:ss")|| '--')
    }
  }),
])

export const queryUserFields = Object.freeze([
  id,
  status,
  mobile
])

export const columns = [{
    key: "_id",
    title: "id",
    type: "text"
  },
  {
    key: "status",
    title: "状态",
    type: "int"
  },
  {
    key: "mobile",
    titile: "mobile"
  }
]